package com.integrate.mybatis.service.impl;


import com.integrate.mybatis.domain.ConsumerUser;
import com.integrate.mybatis.mapper.ConsumerUserMapper;
import com.integrate.mybatis.service.ConsumerUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 刘志强
 * @date 2020/11/27 14:20
 */
@Service
@Slf4j
public class ConsumerUserImpl implements ConsumerUserService {

    @Autowired
    private ConsumerUserMapper consumerUserMapper;

    @Override
    public ConsumerUser getConsumerUser(Long id) {
        return consumerUserMapper.getConsumerUserById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public String addConsumerUser(ConsumerUser consumerUser) {
        int i = consumerUserMapper.addConsumerUser(consumerUser);
        log.info(consumerUser.toString());
        if (i > 0) {
            return "添加成功";
        } else {
            return "添加失败";
        }
    }
}
